package view.hero
{
import core.Language;

import flash.display.MovieClip;
import flash.events.Event;

import framework.proxy.ComponentProxy;
import framework.view.components.scrollbar.ScrollerBarProxy;

import values.common.IAvatarBasicProperty;

import view.component.button.LabelChangeButtonProxy;

/**
 * HeroPropertyInfoProxy
 * @author jliang
 *
 */
public class HeroPropertyInfoProxy extends ComponentProxy
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function HeroPropertyInfoProxy()
	{
		super();
	}
	//==========================================================================
	//  Properties
	//==========================================================================
	
	private var _data:IAvatarBasicProperty;

	public function set data(value:IAvatarBasicProperty):void
	{
		_data = value;
		
		update();
	}

	public function get data():IAvatarBasicProperty
	{
		return _data;
	}
	
	override public function dispose():void
	{
		_data = null;
		super.dispose();
	}
	
	//==========================================================================
	//  Overridden methods: ComponentProxy
	//==========================================================================
	override protected function get proxyMapping():Array
	{
		return [ 
			{skin:"detailBtn" , id:"detailBtn" , classRef:LabelChangeButtonProxy , onClick:onDetailClick , text:Language.getText("@detail_property_label")}
		];
	}
	
	private function onDetailClick():void
	{
		this.dispatchEvent(new Event(Event.SELECT));
	}
	
	override public function parse(target:MovieClip):void
	{
		super.parse(target);
		skin.baseTF.text = Language.getText("@base_property_label");
		skin.hpConstTF.text = Language.getText("@property_maxHP_name");
		skin.normalConstTF.text = Language.getText("@property_normalPower_name");
		skin.skillConstTF.text = Language.getText("@property_skillPower_name");
		skin.elementConstTF.text = Language.getText("@property_elementPower_name");
		skin.moveConstTF.text = Language.getText("@property_moveCapability_name");
		skin.attactConstTF.text = Language.getText("@property_attact_distance_name");
		skin.fightConstTF.text = Language.getText("@property_fight_value_name");
		skin.hpConstTF.text = Language.getText("@property_maxHP_name");
	}
	
	//==========================================================================
	//  Public methods
	//==========================================================================
	public function update():void
	{
		skin.hpTF.text = data.maxHP;
		skin.normalTF.text = data.normalPower;
		skin.skillTF.text = data.skillPower;
		skin.elementTF.text = data.elementPower;
		skin.moveTF.text = data.moveCapability;
		skin.attactTF.text = data.distance;
		skin.fightTF.text = data.maxHP + data.normalPower * 103;
	}
}
}



